using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Lzfy_Refund_Service.Models
{
    /// <summary>
    /// 用户表信息修改痕迹
    /// </summary>
    [Table("LZFY_UUM_USER_MODIFY_LOG", Schema = "UUM")]
    public class UumUserModifyLog
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        [Key]
        [Column("id")]
        public long Id { get; set; }

        /// <summary>
        /// 记录创建时间
        /// </summary>
        [Column("input_date")]
        public DateTime? InputDate { get; set; }

        /// <summary>
        /// 用户名（关联uum.uum_user.user_name）
        /// </summary>
        [Column("user_name")]
        [StringLength(32)]
        public string? UserName { get; set; }

        /// <summary>
        /// 修改的列名
        /// </summary>
        [Column("col_name")]
        [StringLength(32)]
        public string? ColName { get; set; }

        /// <summary>
        /// 修改用户名（关联uum.uum_user.user_name）
        /// </summary>
        [Column("user_name_modify")]
        [StringLength(32)]
        public string? UserNameModify { get; set; }

        /// <summary>
        /// 原始值
        /// </summary>
        [Column("origin_value")]
        [StringLength(32)]
        public string? OriginValue { get; set; }

        /// <summary>
        /// 修改后的值
        /// </summary>
        [Column("update_value")]
        [StringLength(32)]
        public string? UpdateValue { get; set; }
    }

    /// <summary>
    /// 创建用户修改日志请求
    /// </summary>
    public class UumUserModifyLogCreateRequest
    {
        /// <summary>
        /// 用户名（关联uum.uum_user.user_name）
        /// </summary>
        [Required(ErrorMessage = "用户名不能为空")]
        [StringLength(32, ErrorMessage = "用户名长度不能超过32个字符")]
        public string UserName { get; set; } = string.Empty;

        /// <summary>
        /// 修改的列名
        /// </summary>
        [Required(ErrorMessage = "修改的列名不能为空")]
        [StringLength(32, ErrorMessage = "列名长度不能超过32个字符")]
        public string ColName { get; set; } = string.Empty;

        /// <summary>
        /// 修改用户名（关联uum.uum_user.user_name）
        /// </summary>
        [Required(ErrorMessage = "修改用户名不能为空")]
        [StringLength(32, ErrorMessage = "修改用户名长度不能超过32个字符")]
        public string UserNameModify { get; set; } = string.Empty;

        /// <summary>
        /// 原始值
        /// </summary>
        [StringLength(32, ErrorMessage = "原始值长度不能超过32个字符")]
        public string? OriginValue { get; set; }

        /// <summary>
        /// 修改后的值
        /// </summary>
        [StringLength(32, ErrorMessage = "修改后的值长度不能超过32个字符")]
        public string? UpdateValue { get; set; }
    }

    /// <summary>
    /// 用户修改日志查询请求
    /// </summary>
    public class UumUserModifyLogQueryRequest
    {
        /// <summary>
        /// 用户名
        /// </summary>
        public string? UserName { get; set; }

        /// <summary>
        /// 修改的列名
        /// </summary>
        public string? ColName { get; set; }

        /// <summary>
        /// 修改用户名
        /// </summary>
        public string? UserNameModify { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? StartDate { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndDate { get; set; }

        /// <summary>
        /// 页码（从1开始）
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; } = 20;
    }

    /// <summary>
    /// 用户修改日志查询响应
    /// </summary>
    public class UumUserModifyLogQueryResponse
    {
        /// <summary>
        /// 数据列表
        /// </summary>
        public List<UumUserModifyLog> Items { get; set; } = new List<UumUserModifyLog>();

        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
    }

    /// <summary>
    /// 获取最近记录请求
    /// </summary>
    public class GetRecentRequest
    {
        /// <summary>
        /// 最近多少分钟，默认60分钟
        /// </summary>
        public int Minutes { get; set; } = 60;
    }
}